Skip to Content

Data Mutation & Model Extending

This document describes data mutation capabilities available in the current SDK.


Current mutation model

Data mutation is performed through ISharedEntity<T> returned by PlayServ.SelectEntity<TEntity, TDto>(...).

Available operations:

  • Update(Action<T>)
  • UpdateAsync(Action<T>)
  • Refresh() / RefreshAsync()

Bind and mutate

var player = await PlayServ.SelectEntity<SamplePlayerEntity, SamplePlayerDto>( "player-001", entity => new SamplePlayerDto { Id = entity?.Id ?? string.Empty, Name = entity?.Name ?? string.Empty, Level = entity?.Level ?? 0 }); player.Update(dto => { dto.Name = "RenamedPlayer"; dto.Level = 10; }); await player.UpdateAsync(dto => dto.Level++);

Refresh and dispose

await player.RefreshAsync(); if (player is System.IDisposable disposable) disposable.Dispose();

About delete operations

ISharedEntity<T> in current SDK does not expose Delete().

If your domain requires delete semantics, implement it as backend command/RPC and apply state updates through subscription flow.


Model extending in practice

Domain actions are typically modeled as RPC methods on [Rpc] services and invoked via PlayServ.Invoke(...).

This keeps data synchronization (SelectEntity) and command-style actions (Invoke) separated and explicit.


Summary

Current SDK mutation flow is entity-subscription based (SelectEntity + Update/Refresh). Command-like domain behavior is implemented through RPC services.

Last updated on